package com.example.demo.converter;

import com.example.demo.dao.UserDetail;
import com.example.demo.dto.UserDetailDTO;

public class UserDetailConverter {
    public static UserDetailDTO convertUserDetail(UserDetail userDetail){
        if (userDetail == null) {
            return new UserDetailDTO();
        }
        UserDetailDTO userDetailDTO=new UserDetailDTO();
        userDetailDTO.setId(userDetail.getId());
        userDetailDTO.setBio(userDetail.getBio());
        userDetailDTO.setFollowersCount(userDetail.getFollowersCount());
        userDetailDTO.setFollowingCount(userDetail.getFollowingCount());
        userDetailDTO.setImageName(userDetail.getImageName());
        userDetailDTO.setImageBytes(userDetail.getImageBytes());
        userDetailDTO.setGender(userDetail.getGender());
        userDetailDTO.setSchool(userDetail.getSchool());
        userDetailDTO.setBirthday(userDetail.getBirthday());
        userDetailDTO.setLocation(userDetail.getLocation());
        userDetailDTO.setUserDTO(UserConverter.convertUser(userDetail.getUser()));
        return userDetailDTO;
    }
    public static UserDetail convertUserDetail(UserDetailDTO userDetailDTO){
        if (userDetailDTO == null) {
            return new UserDetail();
        }
        UserDetail userDetail=new UserDetail();
        userDetail.setId(userDetailDTO.getId());
        userDetail.setGender(userDetailDTO.getGender());
        userDetail.setImageName(userDetailDTO.getImageName());
        userDetail.setImageBytes(userDetailDTO.getImageBytes());
        userDetail.setBirthday(userDetailDTO.getBirthday());
        userDetail.setSchool(userDetailDTO.getSchool());
        userDetail.setLocation(userDetailDTO.getLocation());
        userDetail.setBio(userDetailDTO.getBio());
        userDetail.setFollowersCount(userDetailDTO.getFollowersCount());
        userDetail.setFollowingCount(userDetailDTO.getFollowingCount());
        userDetail.setUser(UserConverter.convertUser(userDetailDTO.getUserDTO()));
        return userDetail;
    }
}
